#ifndef GRAPH_H
#define GRAPH_H

#include <set>

#include <Klein/Shader/GraphIdentifier.h>
#include <Klein/Shader/Node.h>

class KLEIN_API Graph
{
public:

	Graph(const GraphIdentifier& identifier);
	~Graph();

	const GraphIdentifier& GetIdentifier() const;

	/**
	 * Create a new Node consider the Fragment as a template.
	 */
	NodeRef CreateNode(const FragmentIdentifier& fragmentIdentifier);
	NodeRef GetNode(const int graphNodeNumber) const;
	void CollectNodes(std::vector<NodeRef>& graphNodes);
	void RemoveNode(const int graphNodeNumber);

	void ActiveNode(const int graphNodeNumber);
	int GetActivedNodeNumber() const;

	/**
	 * 1:1
	 */
	bool Connect(const int outputNodeNumber, const String& outputParameterName, const int inputNodeNumber, const String& inputParameterName);

	/**
	 * ...:1
	 */
	void Disconnect(const String& inputSocketIdentifier);

protected:

	GraphIdentifier mIdentifier;

	int mActivedNodeNumber;

	std::map<int, NodeRef> mGraphNumbersToNodes;
};

typedef boost::shared_ptr<Graph> GraphRef;

#endif
